package basic;

public class MTBBike extends Bike {

    private static int ppd = 30; // price per day
    private static int maxDist = 2000; // bike is serviced every maxDist kilometers
    private int shifts;

    public MTBBike() {
        this.setId(Bike.getCurrId());
    }

    public void setShifts(int shifts) {
        this.shifts = shifts;
    }

    public int getShifts() {
        return this.shifts;
    }

    @Override
    public int getPpd() {
        return MTBBike.ppd;
    }

    @Override
    public int getMaxDist() {
        return MTBBike.maxDist;

    }

    @Override
    public void changeMileage(int k) {
        this.mileage = this.mileage + k;
        int g = (int) (this.mileage / MTBBike.maxDist); /// ????

        if (g >= 1) {

            this.setNeedService(true);
            this.serviceCount++;
            this.mileage -= MTBBike.maxDist;
        }
    }

    @Override
    public String toString() {
        // id model wheelsize total_mileage mileage_to_serive shifts
        return String.format("%4d %20s %10d %6d %10d %6d",
                this.getId(), this.getModel(), this.getWheelSize(),
                (this.getServiceCount() * this.getMaxDist() + this.getMileage()),
                this.getMaxDist() - this.getMileage(), this.getShifts());
    }

}
